package com.dekarrin.scraton;

import java.util.Vector;
import java.util.Iterator;
import java.util.Collections;

/**
 * Holds a series of instructions for a screenplay.
 *
 * @author Dekarrin Larimal
 * @version 6/23/12
 */
public class Script implements Iterable<ScriptInstruction> {

	private Vector<ScriptInstruction> instructions;
	
	public Script() {
		instructions = new Vector<ScriptInstruction>();
	}

	public int size() {
		return instructions.size();
	}

	public void addInstruction(ScriptInstruction ins) {
		instructions.add(ins);
	}

	public void sort() {
		Collections.sort(instructions);
	}

	public Iterator<ScriptInstruction> iterator() {
		return instructions.iterator();
	}

	public String toString() {
		StringBuilder str = new StringBuilder();
		for (int i = 0; i < instructions.size(); i++) {
			str.append(instructions.get(i).toString());
		}
		return str.toString();
	}

}